<?php
  include "counter.php";
  pagehead("Places that do not use Linux");

  $join = '?';
?>
<body>
<?php pagetop() ?>
<h1>
<img src="/gifs/Logo-small.png" alt="Linux Counter Logo">
Countries that do not use Linux</h1>

Here you can see the few countries from which not a single Linux user
has registered as of
<?php echo strftime("%a %b %d %H:%M:%S %Y %Z") ?>
<p>
<?php
  if (!$orderby = $counter->get_input('orderby', 'alpha', 'get')) {
  $orderby = 'name'; 
  }
?>
<?php
  if ($orderby == 'longname') {
      $desc = 'asc';
  } else {
      $desc = 'desc';
  }
#  print("SELECT name, longname, population FROM places
#  WHERE type = 'country' AND users = 0 ORDER BY ". $orderby .' '. $desc);
  $query = mysql_query("SELECT name, longname, population FROM places
  WHERE type = 'country' AND users = 0 ORDER BY ". $orderby .' '. $desc);
  if ($query == 0) {
      print('</table>MySQL error: '. mysql_errno() .':'. mysql_error());
      die('Query for count failed');
  }
  $rank = 1;
  while ($arr = mysql_fetch_array($query)) {
      if ($rank == 1) {
?>
<a name="table"></a>
The table is sorted by
<?php
              print $orderby;
?>
<table border=4>
   <tr>
       <th>No</th>
       <th>ID</th>
       <!-- note - RFC 2396 specifies that fragment follows query part -->
       <th><a href="<?php echo $_SERVER['PHP_SELF'].$join ?>orderby=longname#table">Place</a></th>
       <th><a href="<?php echo $_SERVER['PHP_SELF'].$join ?>orderby=population#table">People</a></th>
   </tr>
<?
      }
?>
   <tr align=right>
       <td><?php echo $rank; ?></td>
       <td align=left><?php echo $arr['name']; ?></td>
       <td align=left><a href="/reports/place.php?place=<?php
          echo urlencode($arr['name']);
          print '">'. $arr['longname'] .'</a>';
        ?></td>
       <td><?php if ($arr['population'] >= 1) { printf("%6.1fM", $arr['population']); } elseif ($arr['population'] > 0) { printf("%6.0fK", $arr['population'] * 1000); } else { print('Unknown'); } ?></td>
   </tr>
<?php
      ++$rank;
  }
  if ($rank > 1) {
      echo '</table>';
  }
  pagebottom();
?>
</body>
</html>
